<template>
  <div class="line-echart">
    <echart :option="option"></echart>
  </div>
</template>

<script setup lang="ts">
import { computed, defineProps, withDefaults } from "vue";
import Echart from "../index";
interface Props {
  xAxisData: string[];
  yAxisData: number[];
  seriesName?: string;
}
const props = withDefaults(defineProps<Props>(), { seriesName: "分类销量" });
const option = computed(() => {
  return {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "cross",
        label: {
          backgroundColor: "#6a7985"
        }
      }
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    grid: {
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true
    },
    xAxis: [
      {
        type: "category",
        boundaryGap: false,
        data: props.xAxisData
      }
    ],
    yAxis: [
      {
        type: "value"
      }
    ],
    series: [
      {
        name: props.seriesName,
        type: "line",
        stack: "Total",
        areaStyle: {},
        emphasis: {
          focus: "series"
        },
        data: props.yAxisData
      }
    ]
  };
});
</script>

<style scoped></style>
